<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link href="css/mui.min.css" rel="stylesheet" />
</head>
<body>
	<iframe id="iframe" src="http://192.168.137.1:8080/" 
	frameborder="0" 
	style="position: absolute;width: 100%;
	height: 100%;padding: 0;margin: 0;border: none;"></iframe>
<script src="js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
    mui.init({
		statusBarBackground: "#fffff",
	});
	
	iframe.onload = function() {
		console.log('loaded');
		
		iframe.contentWindow.document.getElementById('btn1').onclick = function() {
			iframe.contentWindow.myfn("data");
		};
		iframe.contentWindow.document.getElementById('btn').onclick = function() {
			window.parent.postMessage({
				name: 'scan'
			},'*')
		}
	}
	window.addEventListener('message',function(event){
		console.log(event.data);
		if (event.data.name === 'scan') {
			toScan()
		}
	});
	window.toScan = function() {
		mui.openWindow({
			url: 'barcode_custome.html',
			styles: {
				titleNView: {
					type: 'transparent',
					titleText: '扫一扫',
					autoBackButton: true,
					buttons: [{
						fontSrc: 'fonts/helloh5.ttf',
						text: '\ue401',
						fontSize: '18px',
						onclick: 'javascript:switchFlash()'
					}]
				}
			}
		});
	};
	window.scaned = function(type,result,path) {
		// 这里可以调用iframe页面里的方法或组件属性
		iframe.contentWindow.document.getElementById('text').value = type + '\n' + result + '\n' + path
	}
</script>
</body>
</html>